inspector: Drop unused python shell code
authorMatthias Clasen <mclasen@redhat.com>
Sat, 11 Oct 2014 00:33:08 +0000 (20:33 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 11 Oct 2014 04:59:36 +0000 (00:59 -0400)
This is getting in the way; if somebody comes by who wants
to add scripting support back, we can resurrect this.

gtk/inspector/Makefile.am
gtk/inspector/init.c
gtk/inspector/python-hooks.c [deleted file]
gtk/inspector/python-hooks.h [deleted file]
gtk/inspector/python-shell.c [deleted file]
gtk/inspector/python-shell.h [deleted file]
gtk/inspector/window.c
gtk/inspector/window.h
gtk/inspector/window.ui
gtk/inspector/window.ui.h

index 0069e6e6ccaccef406aadf4382a39886a9195a7d..9ba97022f88492073d09c67252a477aec3e3b24d 100644 (file)
@@ -44,10 +44,6 @@ libgtkinspector_la_SOURCES =                 \
        prop-list.c                     \
        style-prop-list.h               \
        style-prop-list.c               \
-       python-hooks.h                  \
-       python-hooks.c                  \
-       python-shell.h                  \
-       python-shell.c                  \
        resource-list.h                 \
        resource-list.c                 \
        resources.h                     \
index 8d3ef359f264705f8766d0ed2a1ab410cd80f9c1..4a6a5c5f647d18e5b5106bb9cae4a44261220435 100644 (file)
@@ -34,8 +34,6 @@
 #include "misc-info.h"
 #include "object-hierarchy.h"
 #include "prop-list.h"
-#include "python-hooks.h"
-#include "python-shell.h"
 #include "resource-list.h"
 #include "resources.h"
 #include "signals-list.h"
 void
 gtk_inspector_init (void)
 {
-#ifdef ENABLE_PYTHON
-  gtk_inspector_python_init ();
-#endif
-
   gtk_inspector_register_resource ();
 
   g_type_ensure (GTK_TYPE_INSPECTOR_ACTIONS);
@@ -64,7 +58,6 @@ gtk_inspector_init (void)
   g_type_ensure (GTK_TYPE_INSPECTOR_MISC_INFO);
   g_type_ensure (GTK_TYPE_INSPECTOR_OBJECT_HIERARCHY);
   g_type_ensure (GTK_TYPE_INSPECTOR_PROP_LIST);
-  g_type_ensure (GTK_TYPE_INSPECTOR_PYTHON_SHELL);
   g_type_ensure (GTK_TYPE_INSPECTOR_RESOURCE_LIST);
   g_type_ensure (GTK_TYPE_INSPECTOR_SIGNALS_LIST);
   g_type_ensure (GTK_TYPE_INSPECTOR_STYLE_PROP_LIST);
diff --git a/gtk/inspector/python-hooks.c b/gtk/inspector/python-hooks.c
deleted file mode 100644 (file)
index b8253d2..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (c) 2008-2009  Christian Hammond
- * Copyright (c) 2008-2009  David Trowbridge
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#include <signal.h>
-
-#ifdef ENABLE_PYTHON
-# include <dlfcn.h>
-# include <Python.h>
-# include <pygobject.h>
-#endif
-
-#include "python-hooks.h"
-
-static gboolean python_enabled = FALSE;
-
-#ifdef ENABLE_PYTHON
-static GString *captured_stdout = NULL;
-static GString *captured_stderr = NULL;
-
-
-static PyObject *
-capture_stdout(PyObject *self, PyObject *args)
-{
-    char *str = NULL;
-
-    if (!PyArg_ParseTuple(args, "s", &str))
-        return NULL;
-
-    g_string_append(captured_stdout, str);
-
-    Py_INCREF(Py_None);
-    return Py_None;
-}
-
-static PyObject *
-capture_stderr(PyObject *self, PyObject *args)
-{
-    char *str = NULL;
-
-    if (!PyArg_ParseTuple(args, "s", &str))
-        return NULL;
-
-    g_string_append(captured_stderr, str);
-
-    Py_INCREF(Py_None);
-    return Py_None;
-}
-
-static PyObject *
-wrap_gobj(PyObject *self, PyObject *args)
-{
-    void *addr;
-    GObject *obj;
-
-    if (!PyArg_ParseTuple(args, "l", &addr))
-        return NULL;
-
-    if (!G_IS_OBJECT(addr))
-        return NULL; // XXX
-
-    obj = G_OBJECT(addr);
-
-    if (!obj)
-        return NULL; // XXX
-
-    return pygobject_new(obj);
-}
-
-static PyMethodDef gtk_inspector_python_methods[] = {
-    {"capture_stdout", capture_stdout, METH_VARARGS, "Captures stdout"},
-    {"capture_stderr", capture_stderr, METH_VARARGS, "Captures stderr"},
-    {"gobj", wrap_gobj, METH_VARARGS, "Wraps a C GObject"},
-    {NULL, NULL, 0, NULL}
-};
-
-
-static gboolean
-is_blacklisted(void)
-{
-    const char *prgname = g_get_prgname();
-
-    return (!strcmp(prgname, "gimp"));
-}
-#endif // ENABLE_PYTHON
-
-void
-gtk_inspector_python_init(void)
-{
-#ifdef ENABLE_PYTHON
-    int res;
-    struct sigaction old_sigint;
-
-    if (is_blacklisted())
-        return;
-
-    /* This prevents errors such as "undefined symbol: PyExc_ImportError" */
-    if (!dlopen(PYTHON_SHARED_LIB, RTLD_NOW | RTLD_GLOBAL))
-    {
-        g_error("%s\n", dlerror());
-        return;
-    }
-
-    captured_stdout = g_string_new("");
-    captured_stderr = g_string_new("");
-
-    /* Back up and later restore SIGINT so Python doesn't steal it from us. */
-    res = sigaction(SIGINT, NULL, &old_sigint);
-
-    if (!Py_IsInitialized())
-        Py_Initialize();
-
-    res = sigaction(SIGINT, &old_sigint, NULL);
-
-    Py_InitModule("gtk_inspector", gtk_inspector_python_methods);
-    PyRun_SimpleString(
-        "import gtk_inspector\n"
-        "import sys\n"
-        "\n"
-        "class StdoutCatcher:\n"
-        "    def write(self, str):\n"
-        "        gtk_inspector.capture_stdout(str)\n"
-        "\n"
-        "class StderrCatcher:\n"
-        "    def write(self, str):\n"
-        "        gtk_inspector.capture_stderr(str)\n"
-        "\n"
-    );
-
-    if (!pygobject_init(-1, -1, -1))
-    {
-        fprintf(stderr, "Error initializing pygobject support.\n");
-        PyErr_Print();
-        return;
-    }
-
-    char *argv[] = { "", NULL };
-    PySys_SetArgv(0, argv);
-
-    if (!PyImport_ImportModule("gi._gobject"))
-      {
-        PyErr_SetString(PyExc_ImportError, "could not import gi.gobject");
-        return;
-      }
-    if (!PyImport_ImportModule("gi.repository"))
-      {
-        PyErr_SetString(PyExc_ImportError, "could not import gi.repository");
-        return;
-      }
-    if (!PyImport_ImportModule("gi.repository.Gtk"))
-      {
-        PyErr_SetString(PyExc_ImportError, "could not import gtk");
-        return;
-      }
-
-    python_enabled = TRUE;
-#endif // ENABLE_PYTHON
-}
-
-void
-gtk_inspector_python_run(const char *command,
-                    GtkInspectorPythonLogger stdout_logger,
-                    GtkInspectorPythonLogger stderr_logger,
-                    gpointer user_data)
-{
-#ifdef ENABLE_PYTHON
-    PyGILState_STATE gstate;
-    PyObject *module;
-    PyObject *dict;
-    PyObject *obj;
-
-    gstate = PyGILState_Ensure();
-
-    module = PyImport_AddModule("__main__");
-    dict = PyModule_GetDict(module);
-
-    PyRun_SimpleString("old_stdout = sys.stdout\n"
-                       "old_stderr = sys.stderr\n"
-                       "sys.stdout = StdoutCatcher()\n"
-                       "sys.stderr = StderrCatcher()\n");
-
-    obj = PyRun_String(command, Py_single_input, dict, dict);
-
-    PyRun_SimpleString("sys.stdout = old_stdout\n"
-                       "sys.stderr = old_stderr\n");
-
-    if (stdout_logger != NULL)
-        stdout_logger(captured_stdout->str, user_data);
-
-    if (stderr_logger != NULL)
-        stderr_logger(captured_stderr->str, user_data);
-
-    // Print any returned object
-    if (obj != NULL && obj != Py_None) {
-       PyObject *repr = PyObject_Repr(obj);
-       if (repr != NULL) {
-           char *string = PyString_AsString(repr);
-
-           stdout_logger(string, user_data);
-           stdout_logger("\n", user_data);
-        }
-
-        Py_XDECREF(repr);
-    }
-    Py_XDECREF(obj);
-
-    PyGILState_Release(gstate);
-    g_string_erase(captured_stdout, 0, -1);
-    g_string_erase(captured_stderr, 0, -1);
-#endif // ENABLE_PYTHON
-}
-
-gboolean
-gtk_inspector_python_is_enabled(void)
-{
-    return python_enabled;
-}
-
-// vim: set et sw=4 ts=4:
diff --git a/gtk/inspector/python-hooks.h b/gtk/inspector/python-hooks.h
deleted file mode 100644 (file)
index 331fe74..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2008-2009  Christian Hammond
- * Copyright (c) 2008-2009  David Trowbridge
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#ifndef _GTK_INSPECTOR_PYTHON_MODULE_H_
-#define _GTK_INSPECTOR_PYTHON_MODULE_H_
-
-#include <glib.h>
-
-
-typedef void (*GtkInspectorPythonLogger)(const char *text, gpointer user_data);
-
-void gtk_inspector_python_init(void);
-void gtk_inspector_python_run(const char *command,
-                         GtkInspectorPythonLogger stdout_logger,
-                         GtkInspectorPythonLogger stderr_logger,
-                         gpointer user_data);
-gboolean gtk_inspector_python_is_enabled(void);
-
-#endif // _GTK_INSPECTOR_PYTHON_MODULE_H_
diff --git a/gtk/inspector/python-shell.c b/gtk/inspector/python-shell.c
deleted file mode 100644 (file)
index cb5f08e..0000000
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * Copyright (c) 2008-2009  Christian Hammond
- * Copyright (c) 2008-2009  David Trowbridge
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#include "config.h"
-#include <glib/gi18n-lib.h>
-
-#include <gdk/gdkkeysyms.h>
-#include <string.h>
-
-#include "python-hooks.h"
-#include "python-shell.h"
-
-#include "gtkscrolledwindow.h"
-#include "gtktextview.h"
-
-#define MAX_HISTORY_LENGTH 20
-
-struct _GtkInspectorPythonShellPrivate
-{
-    GtkWidget *textview;
-
-    GtkTextMark *scroll_mark;
-    GtkTextMark *line_start_mark;
-
-    GQueue *history;
-    GList *cur_history_item;
-
-    GString *pending_command;
-    gboolean in_block;
-};
-
-G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorPythonShell, gtk_inspector_python_shell, GTK_TYPE_BOX);
-
-/* Widget functions */
-static void gtk_inspector_python_shell_finalize (GObject *obj);
-
-/* Python integration */
-static void gtk_inspector_python_shell_write_prompt(GtkWidget *python_shell);
-static char *gtk_inspector_python_shell_get_input(GtkWidget *python_shell);
-
-/* Callbacks */
-static gboolean gtk_inspector_python_shell_key_press_cb(GtkWidget *textview,
-                                                   GdkEventKey *event,
-                                                   GtkWidget *python_shell);
-static void
-gtk_inspector_python_shell_class_init(GtkInspectorPythonShellClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-    object_class->finalize = gtk_inspector_python_shell_finalize;
-}
-
-static void
-gtk_inspector_python_shell_init (GtkInspectorPythonShell *python_shell)
-{
-    GtkWidget *swin;
-    GtkTextBuffer *buffer;
-    GtkTextIter iter;
-
-    python_shell->priv = gtk_inspector_python_shell_get_instance_private (python_shell);
-
-    python_shell->priv->history = g_queue_new();
-
-    gtk_box_set_spacing(GTK_BOX(python_shell), 6);
-
-    swin = gtk_scrolled_window_new(NULL, NULL);
-    gtk_widget_show(swin);
-    gtk_box_pack_start(GTK_BOX(python_shell), swin, TRUE, TRUE, 0);
-    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
-                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
-    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin),
-                                        GTK_SHADOW_IN);
-
-    python_shell->priv->textview = gtk_text_view_new();
-    gtk_text_view_set_monospace (GTK_TEXT_VIEW (python_shell->priv->textview), TRUE);
-    gtk_widget_show(python_shell->priv->textview);
-    gtk_container_add(GTK_CONTAINER(swin), python_shell->priv->textview);
-    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(python_shell->priv->textview), TRUE);
-    gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(python_shell->priv->textview), 3);
-    gtk_text_view_set_left_margin(GTK_TEXT_VIEW(python_shell->priv->textview), 3);
-    gtk_text_view_set_right_margin(GTK_TEXT_VIEW(python_shell->priv->textview), 3);
-
-    g_signal_connect(python_shell->priv->textview, "key_press_event",
-                     G_CALLBACK(gtk_inspector_python_shell_key_press_cb),
-                     python_shell);
-
-    /* Create the end-of-buffer mark */
-    buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(python_shell->priv->textview));
-    gtk_text_buffer_get_end_iter(buffer, &iter);
-    python_shell->priv->scroll_mark = gtk_text_buffer_create_mark(buffer, "scroll_mark",
-                                                    &iter, FALSE);
-
-    /* Create the beginning-of-line mark */
-    python_shell->priv->line_start_mark = gtk_text_buffer_create_mark(buffer,
-                                                        "line_start_mark",
-                                                        &iter, TRUE);
-
-    /* Register some tags */
-    gtk_text_buffer_create_tag(buffer, "stdout", NULL);
-    gtk_text_buffer_create_tag(buffer, "stderr",
-                               "foreground", "red",
-                               "paragraph-background", "#FFFFE0",
-                               NULL);
-    gtk_text_buffer_create_tag(buffer, "prompt",
-                               "foreground", "blue",
-                               NULL);
-
-    gtk_inspector_python_shell_write_prompt(GTK_WIDGET(python_shell));
-}
-
-static void
-gtk_inspector_python_shell_finalize(GObject *python_shell)
-{
-    GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv;
-
-    g_queue_free(priv->history);
-}
-
-static void
-gtk_inspector_python_shell_log_stdout(const char *text, gpointer python_shell)
-{
-    gtk_inspector_python_shell_append_text(GTK_INSPECTOR_PYTHON_SHELL(python_shell),
-                                      text, "stdout");
-}
-
-static void
-gtk_inspector_python_shell_log_stderr(const char *text, gpointer python_shell)
-{
-    gtk_inspector_python_shell_append_text(GTK_INSPECTOR_PYTHON_SHELL(python_shell),
-                                      text, "stderr");
-}
-
-static void
-gtk_inspector_python_shell_write_prompt(GtkWidget *python_shell)
-{
-    GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv;
-    GtkTextBuffer *buffer =
-        gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->textview));
-    GtkTextIter iter;
-    const char *prompt = (priv->pending_command == NULL ? ">>> " : "... ");
-
-    gtk_inspector_python_shell_append_text(GTK_INSPECTOR_PYTHON_SHELL(python_shell),
-                                      prompt, "prompt");
-
-    gtk_text_buffer_get_end_iter(buffer, &iter);
-    gtk_text_buffer_move_mark(buffer, priv->line_start_mark, &iter);
-}
-
-static void
-gtk_inspector_python_shell_process_line(GtkWidget *python_shell)
-{
-    GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv;
-    char *command = gtk_inspector_python_shell_get_input(python_shell);
-    char last_char;
-
-    gtk_inspector_python_shell_append_text(GTK_INSPECTOR_PYTHON_SHELL(python_shell),
-                                      "\n", NULL);
-
-    if (*command != '\0')
-    {
-        /* Save this command in the history. */
-        g_queue_push_head(priv->history, command);
-        priv->cur_history_item = NULL;
-
-        if (g_queue_get_length(priv->history) > MAX_HISTORY_LENGTH)
-            g_free(g_queue_pop_tail(priv->history));
-    }
-
-    last_char = command[MAX(0, strlen(command) - 1)];
-
-    if (last_char == ':' || last_char == '\\' ||
-        (priv->in_block && g_ascii_isspace(command[0])))
-    {
-        printf("in block.. %c, %d, %d\n",
-               last_char, priv->in_block,
-               g_ascii_isspace(command[0]));
-        /* This is a multi-line expression */
-        if (priv->pending_command == NULL)
-            priv->pending_command = g_string_new(command);
-        else
-            g_string_append(priv->pending_command, command);
-
-        g_string_append_c(priv->pending_command, '\n');
-
-        if (last_char == ':')
-            priv->in_block = TRUE;
-    }
-    else
-    {
-        if (priv->pending_command != NULL)
-        {
-            g_string_append(priv->pending_command, command);
-            g_string_append_c(priv->pending_command, '\n');
-
-            /* We're not actually leaking this. It's in the history. */
-            command = g_string_free(priv->pending_command, FALSE);
-        }
-
-        gtk_inspector_python_run(command,
-                            gtk_inspector_python_shell_log_stdout,
-                            gtk_inspector_python_shell_log_stderr,
-                            python_shell);
-
-        if (priv->pending_command != NULL)
-        {
-            /* Now do the cleanup. */
-            g_free(command);
-            priv->pending_command = NULL;
-            priv->in_block = FALSE;
-        }
-    }
-
-    gtk_inspector_python_shell_write_prompt(python_shell);
-}
-
-static void
-gtk_inspector_python_shell_replace_input(GtkWidget *python_shell,
-                                    const char *text)
-{
-    GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv;
-    GtkTextBuffer *buffer =
-        gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->textview));
-    GtkTextIter start_iter;
-    GtkTextIter end_iter;
-
-    gtk_text_buffer_get_iter_at_mark(buffer, &start_iter,
-                                     priv->line_start_mark);
-    gtk_text_buffer_get_end_iter(buffer, &end_iter);
-
-    gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
-    gtk_text_buffer_insert(buffer, &end_iter, text, -1);
-}
-
-static char *
-gtk_inspector_python_shell_get_input(GtkWidget *python_shell)
-{
-    GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv;
-    GtkTextBuffer *buffer =
-        gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->textview));
-    GtkTextIter start_iter;
-    GtkTextIter end_iter;
-
-    gtk_text_buffer_get_iter_at_mark(buffer, &start_iter,
-                                     priv->line_start_mark);
-    gtk_text_buffer_get_end_iter(buffer, &end_iter);
-
-    return gtk_text_buffer_get_text(buffer, &start_iter, &end_iter, FALSE);
-}
-
-static const char *
-gtk_inspector_python_shell_get_history_back(GtkWidget *python_shell)
-{
-    GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv;
-
-    if (priv->cur_history_item == NULL)
-    {
-        priv->cur_history_item = g_queue_peek_head_link(priv->history);
-
-        if (priv->cur_history_item == NULL)
-            return "";
-    }
-    else if (priv->cur_history_item->next != NULL)
-        priv->cur_history_item = priv->cur_history_item->next;
-
-    return (const char *)priv->cur_history_item->data;
-}
-
-static const char *
-gtk_inspector_python_shell_get_history_forward(GtkWidget *python_shell)
-{
-    GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv;
-
-    if (priv->cur_history_item == NULL || priv->cur_history_item->prev == NULL)
-    {
-        priv->cur_history_item = NULL;
-        return "";
-    }
-
-    priv->cur_history_item = priv->cur_history_item->prev;
-
-    return (const char *)priv->cur_history_item->data;
-}
-
-static gboolean
-gtk_inspector_python_shell_key_press_cb(GtkWidget *textview,
-                                   GdkEventKey *event,
-                                   GtkWidget *python_shell)
-{
-    if (event->keyval == GDK_KEY_Return)
-    {
-        gtk_inspector_python_shell_process_line(python_shell);
-        return TRUE;
-    }
-    else if (event->keyval == GDK_KEY_Up)
-    {
-        gtk_inspector_python_shell_replace_input(python_shell,
-            gtk_inspector_python_shell_get_history_back(python_shell));
-        return TRUE;
-    }
-    else if (event->keyval == GDK_KEY_Down)
-    {
-        gtk_inspector_python_shell_replace_input(python_shell,
-            gtk_inspector_python_shell_get_history_forward(python_shell));
-        return TRUE;
-    }
-    else if (event->string != NULL)
-    {
-        GtkInspectorPythonShellPrivate *priv = GTK_INSPECTOR_PYTHON_SHELL(python_shell)->priv;
-        GtkTextBuffer *buffer =
-            gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->textview));
-        GtkTextMark *insert_mark = gtk_text_buffer_get_insert(buffer);
-        GtkTextMark *selection_mark =
-            gtk_text_buffer_get_selection_bound(buffer);
-        GtkTextIter insert_iter;
-        GtkTextIter selection_iter;
-        GtkTextIter start_iter;
-        gint cmp_start_insert;
-        gint cmp_start_select;
-        gint cmp_insert_select;
-
-        gtk_text_buffer_get_iter_at_mark(buffer, &start_iter,
-                                         priv->line_start_mark);
-        gtk_text_buffer_get_iter_at_mark(buffer, &insert_iter, insert_mark);
-        gtk_text_buffer_get_iter_at_mark(buffer, &selection_iter,
-                                         selection_mark);
-
-        cmp_start_insert = gtk_text_iter_compare(&start_iter, &insert_iter);
-        cmp_start_select = gtk_text_iter_compare(&start_iter, &selection_iter);
-        cmp_insert_select = gtk_text_iter_compare(&insert_iter,
-                                                  &selection_iter);
-
-        if (cmp_start_insert == 0 && cmp_start_select == 0 &&
-            (event->keyval == GDK_KEY_BackSpace ||
-             event->keyval == GDK_KEY_Left))
-        {
-            return TRUE;
-        }
-        if (cmp_start_insert <= 0 && cmp_start_select <= 0)
-        {
-            return FALSE;
-        }
-        else if (cmp_start_insert > 0 && cmp_start_select > 0)
-        {
-            gtk_text_buffer_place_cursor(buffer, &start_iter);
-        }
-        else if (cmp_insert_select < 0)
-        {
-            gtk_text_buffer_move_mark(buffer, insert_mark, &start_iter);
-        }
-        else if (cmp_insert_select > 0)
-        {
-            gtk_text_buffer_move_mark(buffer, selection_mark, &start_iter);
-        }
-    }
-
-    return FALSE;
-}
-
-GtkWidget *
-gtk_inspector_python_shell_new(void)
-{
-    return g_object_new(GTK_TYPE_INSPECTOR_PYTHON_SHELL, NULL);
-}
-
-void
-gtk_inspector_python_shell_append_text(GtkInspectorPythonShell *python_shell,
-                                  const char *str,
-                                  const char *tag)
-{
-    GtkInspectorPythonShellPrivate *priv = python_shell->priv;
-
-    GtkTextIter end;
-    GtkTextBuffer *buffer =
-        gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->textview));
-    GtkTextMark *mark = gtk_text_buffer_get_insert(buffer);
-
-    gtk_text_buffer_get_end_iter(buffer, &end);
-    gtk_text_buffer_move_mark(buffer, mark, &end);
-    gtk_text_buffer_insert_with_tags_by_name(buffer, &end, str, -1, tag, NULL);
-    gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(priv->textview), mark,
-                                 0, TRUE, 0, 1);
-}
-
-void
-gtk_inspector_python_shell_focus(GtkInspectorPythonShell *python_shell)
-{
-   gtk_widget_grab_focus (python_shell->priv->textview);
-}
-
-// vim: set et ts=4:
diff --git a/gtk/inspector/python-shell.h b/gtk/inspector/python-shell.h
deleted file mode 100644 (file)
index e1065e9..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2008-2009  Christian Hammond
- * Copyright (c) 2008-2009  David Trowbridge
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#ifndef _GTK_INSPECTOR_PYTHON_SHELL_H_
-#define _GTK_INSPECTOR_PYTHON_SHELL_H_
-
-typedef struct _GtkInspectorPythonShell         GtkInspectorPythonShell;
-typedef struct _GtkInspectorPythonShellClass    GtkInspectorPythonShellClass;
-typedef struct _GtkInspectorPythonShellPrivate  GtkInspectorPythonShellPrivate;
-
-#include <gtk/gtkbox.h>
-
-#define GTK_TYPE_INSPECTOR_PYTHON_SHELL (gtk_inspector_python_shell_get_type())
-#define GTK_INSPECTOR_PYTHON_SHELL(obj) \
-               (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_PYTHON_SHELL, GtkInspectorPythonShell))
-#define GTK_INSPECTOR_PYTHON_SHELL_CLASS(klass) \
-               (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_PYTHON_SHELL, GtkInspectorPythonShellClass))
-#define GTK_INSPECTOR_IS_PYTHON_SHELL(obj) \
-               (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_PYTHON_SHELL))
-#define GTK_INSPECTOR_IS_PYTHON_SHELL_CLASS(klass) \
-               (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_PYTHON_SHELL))
-#define GTK_INSPECTOR_PYTHON_SHELL_GET_CLASS(obj) \
-               (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_INSPECTOR_PYTHON_SHELL, GtkInspectorPythonShellClass))
-
-
-struct _GtkInspectorPythonShell
-{
-  GtkBox parent_object;
-  GtkInspectorPythonShellPrivate *priv;
-};
-
-struct _GtkInspectorPythonShellClass
-{
- GtkBoxClass parent_class;
-};
-
-G_BEGIN_DECLS
-
-GType gtk_inspector_python_shell_get_type(void);
-
-GtkWidget *gtk_inspector_python_shell_new(void);
-void gtk_inspector_python_shell_append_text(GtkInspectorPythonShell *python_shell,
-                                       const char *str,
-                                       const char *tag);
-void gtk_inspector_python_shell_focus(GtkInspectorPythonShell *python_shell);
-
-G_END_DECLS
-
-#endif // _GTK_INSPECTOR_PYTHON_SHELL_H_
index aca96761beabbc02e675414d142646353c0cc51b..4d7a05b4bc2780a8850ff23a40a4e15ce36c3a70 100644 (file)
@@ -33,8 +33,6 @@
 #include "css-editor.h"
 #include "object-hierarchy.h"
 #include "widget-tree.h"
-#include "python-hooks.h"
-#include "python-shell.h"
 #include "size-groups.h"
 #include "style-prop-list.h"
 #include "data-list.h"
 
 G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
 
-static gboolean
-on_widget_tree_button_press (GtkInspectorWidgetTree *wt,
-                             GdkEventButton         *event,
-                             GtkInspectorWindow     *iw)
-{
-  if (event->button == 3)
-    gtk_menu_popup (GTK_MENU (iw->widget_popup), NULL, NULL,
-                    NULL, NULL, event->button, event->time);
-
-  return FALSE;
-}
-
 static void
 on_widget_tree_selection_changed (GtkInspectorWidgetTree *wt,
                                   GtkInspectorWindow     *iw)
@@ -108,40 +94,12 @@ on_widget_tree_selection_changed (GtkInspectorWidgetTree *wt,
     gtk_inspector_flash_widget (iw, GTK_WIDGET (selected));
 }
 
-static void
-on_send_widget_to_shell_activate (GtkWidget          *menuitem,
-                                  GtkInspectorWindow *iw)
-{
-  gchar *str;
-  GObject *object;
-
-  object = gtk_inspector_widget_tree_get_selected_object (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree));
-
-  if (!object)
-    return;
-
-  str = g_strdup_printf ("gtk_inspector.gobj(%p)", object);
-  gtk_inspector_python_shell_append_text (GTK_INSPECTOR_PYTHON_SHELL (iw->python_shell),
-                                          str,
-                                          NULL);
-
-  g_free (str);
-  gtk_inspector_python_shell_focus (GTK_INSPECTOR_PYTHON_SHELL (iw->python_shell));
-}
-
 static void
 gtk_inspector_window_init (GtkInspectorWindow *iw)
 {
   gtk_widget_init_template (GTK_WIDGET (iw));
 
   gtk_window_group_add_window (gtk_window_group_new (), GTK_WINDOW (iw));
-
-  if (gtk_inspector_python_is_enabled ())
-    {
-      gtk_widget_show (iw->python_shell);
-      g_signal_connect (G_OBJECT (iw->widget_tree), "button-press-event",
-                        G_CALLBACK (on_widget_tree_button_press), iw);
-    }
 }
 
 static void
@@ -173,8 +131,6 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, style_prop_list);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_css_editor);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_hierarchy);
-  gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, python_shell);
-  gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_popup);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, size_groups);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, data_list);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, actions);
@@ -184,7 +140,6 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
 
   gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect);
   gtk_widget_class_bind_template_callback (widget_class, on_widget_tree_selection_changed);
-  gtk_widget_class_bind_template_callback (widget_class, on_send_widget_to_shell_activate);
 }
 
 GtkWidget *
index ce6fe16a39e82f3ec5f6d4b6a27e7c99a92c70a7..b719f165acaca12dbd376185f0cecc56f93dd3b6 100644 (file)
@@ -47,7 +47,6 @@ typedef struct
   GtkWidget *child_prop_list;
   GtkWidget *signals_list;
   GtkWidget *style_prop_list;
-  GtkWidget *python_shell;
   GtkWidget *classes_list;
   GtkWidget *widget_css_editor;
   GtkWidget *object_hierarchy;
@@ -58,8 +57,6 @@ typedef struct
   GtkWidget *misc_info;
   GtkWidget *gestures;
 
-  GtkWidget *widget_popup;
-
   GtkWidget *selected_widget;
   GtkWidget *flash_widget;
 
index 50b611ddd7355ffa0fd507b6057f87c39f3831b3..4c307c39a542e9d5da4cf4b31a410dc8a0e00dcf 100644 (file)
@@ -5,16 +5,6 @@
     <property name="icon-name">find-location-symbolic</property>
     <property name="icon-size">4</property>
   </object>
-  <object class="GtkMenu" id="widget_popup">
-    <property name="visible">True</property>
-    <child>
-      <object class="GtkMenuItem">
-        <property name="visible">True</property>
-        <property name="label" translatable="yes">Send Widget to Shell</property>
-        <signal name="activate" handler="on_send_widget_to_shell_activate"/>
-      </object>
-    </child>
-  </object>
   <template class="GtkInspectorWindow" parent="GtkWindow">
     <property name="default-height">500</property>
     <property name="default-width">1000</property>
                 <property name="visible">True</property>
                 <property name="orientation">horizontal</property>
                 <child>
-                  <object class="GtkPaned">
+                  <object class="GtkScrolledWindow">
                     <property name="visible">True</property>
-                    <property name="orientation">vertical</property>
+                    <property name="hscrollbar-policy">automatic</property>
+                    <property name="vscrollbar-policy">always</property>
+                    <property name="shadow-type">in</property>
+                    <property name="width-request">250</property>
+                    <property name="expand">True</property>
                     <child>
-                      <object class="GtkScrolledWindow">
+                      <object class="GtkInspectorWidgetTree" id="widget_tree">
                         <property name="visible">True</property>
-                        <property name="hscrollbar-policy">automatic</property>
-                        <property name="vscrollbar-policy">always</property>
-                        <property name="shadow-type">in</property>
-                        <property name="width-request">250</property>
-                        <property name="expand">True</property>
-                        <child>
-                          <object class="GtkInspectorWidgetTree" id="widget_tree">
-                            <property name="visible">True</property>
-                            <signal name="widget-changed" handler="on_widget_tree_selection_changed"/>
-                          </object>
-                        </child>
+                        <signal name="widget-changed" handler="on_widget_tree_selection_changed"/>
                       </object>
-                      <packing>
-                        <property name="resize">True</property>
-                        <property name="shrink">False</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkInspectorPythonShell" id="python_shell">
-                        <property name="visible">False</property>
-                      </object>
-                      <packing>
-                        <property name="resize">False</property>
-                        <property name="shrink">False</property>
-                      </packing>
                     </child>
                   </object>
                   <packing>
index 8d8a11386c117ec0523b12dd773b057565cb98f8..88188ac08d8580ba68ffd1d78abb871cfca8afc9 100644 (file)
@@ -1,4 +1,3 @@
-N_("Send Widget to Shell");
 N_("Select an Object");
 N_("Miscellaneous");
 N_("Properties");